import Router from '@koa/router';
import SystemConfigController from '@/controllers/SystemConfigController';
import auth from '@/middlewares/auth';

const router = new Router({
  prefix: '/api/system-configs',
});

// 所有路由都需要认证
router.use(auth);

/**
 * @route   GET /api/system-configs
 * @desc    获取配置列表
 * @access  Private
 */
router.get('/', SystemConfigController.list);

/**
 * @route   GET /api/system-configs/:key
 * @desc    获取单个配置
 * @access  Private
 */
router.get('/:key', SystemConfigController.get);

/**
 * @route   POST /api/system-configs
 * @desc    设置/更新配置
 * @access  Private
 */
router.post('/', SystemConfigController.set);

/**
 * @route   POST /api/system-configs/batch
 * @desc    批量设置配置
 * @access  Private
 */
router.post('/batch', SystemConfigController.batchSet);

/**
 * @route   DELETE /api/system-configs/:key
 * @desc    删除配置
 * @access  Private
 */
router.del('/:key', SystemConfigController.delete);

export default router;

